home *** CD-ROM | disk | FTP | other *** search
-
-
-
- Tcl_ExprLong(3) Tcl Library Procedures 7.0
-
-
-
- _________________________________________________________________
-
- NAME
- Tcl_ExprLong, Tcl_ExprDouble, Tcl_ExprBool, Tcl_ExprString -
- evaluate an expression
-
- SYNOPSIS
- #include <tcl.h>
-
- int
- Tcl_ExprLong(_i_n_t_e_r_p, _s_t_r_i_n_g, _l_o_n_g_P_t_r)
-
- int
- Tcl_ExprDouble(_i_n_t_e_r_p, _s_t_r_i_n_g, _d_o_u_b_l_e_P_t_r)
-
- int
- Tcl_ExprBoolean(_i_n_t_e_r_p, _s_t_r_i_n_g, _b_o_o_l_e_a_n_P_t_r)
-
- int
- Tcl_ExprString(_i_n_t_e_r_p, _s_t_r_i_n_g)
-
- ARGUMENTS
- Tcl_Interp *_i_n_t_e_r_p (in) Interpreter in whose
- context to evaluate
- _s_t_r_i_n_g.
-
- char *_s_t_r_i_n_g (in) Expression to be
- evaluated. Must be in
- writable memory (the
- expression parser makes
- temporary modifications
- to the string during
- parsing, which it
- undoes before return-
- ing).
-
- long *_l_o_n_g_P_t_r (out) Pointer to location in
- which to store the
- integer value of the
- expression.
-
- int *_d_o_u_b_l_e_P_t_r (out) Pointer to location in
- which to store the
- floating-point value of
- the expression.
-
- int *_b_o_o_l_e_a_n_P_t_r (out) Pointer to location in
- which to store the 0/1
- boolean value of the
- expression.
- _________________________________________________________________
-
-
-
-
- Tcl 1
-
-
-
-
-
-
- Tcl_ExprLong(3) Tcl Library Procedures 7.0
-
-
-
- DESCRIPTION
- These four procedures all evaluate an expression, returning
- the result in one of four different forms. The expression
- is given by the _s_t_r_i_n_g argument, and it can have any of the
- forms accepted by the expr command. The _i_n_t_e_r_p argument
- refers to an interpreter used to evaluate the expression
- (e.g. for variables and nested Tcl commands) and to return
- error information. _I_n_t_e_r_p->_r_e_s_u_l_t is assumed to be initial-
- ized in the standard fashion when any of the procedures are
- invoked.
-
- For all of these procedures the return value is a standard
- Tcl result: TCL_OK means the expression was succesfully
- evaluated, and TCL_ERROR means that an error occurred while
- evaluating the expression. If TCL_ERROR is returned then
- _i_n_t_e_r_p->_r_e_s_u_l_t will hold a message describing the error. If
- an error occurs while executing a Tcl command embedded in
- the expression then that error will be returned.
-
- If the expression is successfully evaluated, then its value
- is returned in one of four forms, depending on which pro-
- cedure is invoked. Tcl_ExprLong stores an integer value at
- *_l_o_n_g_P_t_r. If the expression's actual value is a floating-
- point number, then it is truncated to an integer. If the
- expression's actual value is a non-numeric string then an
- error is returned.
-
- Tcl_ExprDouble stores a floating-point value at *_d_o_u_b_l_e_P_t_r.
- If the expression's actual value is an integer, it is con-
- verted to floating-point. If the expression's actual value
- is a non-numeric string then an error is returned.
-
- Tcl_ExprBoolean stores a 0/1 integer value at *_b_o_o_l_e_a_n_P_t_r.
- If the expression's actual value is an integer or floating-
- point number, then Tcl_ExprBoolean stores 0 at *_b_o_o_l_e_a_n_P_t_r
- if the value was zero and 1 otherwise. If the expression's |
- actual value is a non-numeric string then it must be one of |
- the values accepted by Tcl_GetBoolean, such as ``yes'' or |
- ``no'', or else an error occurs.
-
- Tcl_ExprString returns the value of the expression as a
- string stored in _i_n_t_e_r_p->_r_e_s_u_l_t. If the expression's actual |
- value is an integer then Tcl_ExprString converts it to a |
- string using sprintf with a ``%d'' converter. If the |
- expression's actual value is a floating-point number, then |
- Tcl_ExprString calls Tcl_PrintDouble to convert it to a |
- string.
-
-
- KEYWORDS
- boolean, double, evaluate, expression, integer, string
-
-
-
-
- Tcl 2
-
-
-
-